package sps

import (
	mysql "db2s/MySQL"
	oracle "db2s/Oracle"
	sqlserver "db2s/SqlServer"
	"db2s/cluster"
	"db2s/global"
	"reflect"
	"sync"
)

var mutex sync.Mutex

func reflectMap(value, n any) {
	global.MapStructValues(reflect.ValueOf(value), reflect.ValueOf(n).Elem())
}
func oracleRef(s, d any) any {
	reflectMap(s, d)
	return d
}
func mysqlRef(s, d any) any {
	reflectMap(s, d)
	return d
}
func clusterRef(s, d any) any {
	reflectMap(s, d)
	return d
}
func sqlserverRef(s, d any) any {
	reflectMap(s, d)
	return d
}

var (
	dbTypeInterFuncRef = map[string]reflect.Value{
		"cluster":   reflect.ValueOf(clusterRef),
		"mysql":     reflect.ValueOf(mysqlRef),
		"oracle":    reflect.ValueOf(oracleRef),
		"sqlserver": reflect.ValueOf(sqlserverRef),
	}
)

type ParseS struct {
	DBType string
}

func GetParseS(s string) *ParseS {
	return &ParseS{DBType: s}
}

type ParseEr interface {
}

var (
	sumApi = map[string]any{
		"mysql":     &mysql.TableSum{},
		"oracle":    &oracle.TableSum{},
		"cluster":   &gr.TableSum{},
		"sqlserver": &sqlserver.TableSum{},
	}
)
